/*
 * ipaddr.h
 *
 *  Created on: 2009-3-30
 *      Author: tian
 */

#ifndef IPADDR_H_
#define IPADDR_H_


struct in_addr{
	//Temporary ipv4 address,32 bits
	unsigned char part[4];
};
struct sockaddr{
	struct in_addr peer_ip;
	struct in_addr my_ip;
	unsigned short peer_port;
	unsigned short my_port;
};


/* this function converts a string pointed to by strptr to a
 * struct in_addr.
 * return value:inet_aton returns a negtive value when strptr
 * does not point to a valid net address, and 0 is returned if
 * the conversion is succeed.
 */
int inet_aton(const char *strptr,struct in_addr *addrptr);


/* this function converts a struct in_addr to a string
 * return value:inet_aton returns a pointer to a string
 * which presents ip address in a number-and-dots notation.
 */
char *inet_ntoa(struct in_addr inaddr);

#endif /* IPADDR_H_ */
